//
// Copyright (c) 2009 All Right Reserved
//
// vl
//
// 2009-01-01
// Contains ...
using System.Text;
using JetBrains.Annotations;
namespace LargoCommon.Music
{
///
/// Musical Area.
///
public class MusicalArea {
#region Constructors
///
/// Initializes a new instance of the class.
///
/// The given start.
/// The given end.
public MusicalArea(MusicalPoint givenStart, MusicalPoint givenEnd)
{
this.StartPoint = givenStart;
this.EndPoint = givenEnd;
}
#endregion
#region Properties
///
/// Gets the start point.
///
///
/// The start point.
///
public MusicalPoint StartPoint { get; }
///
/// Gets the end point.
///
///
/// The end point.
///
public MusicalPoint EndPoint { get; }
///
/// Gets a value indicating whether multiple selection.
///
/// Property description.
[UsedImplicitly]
public bool IsSimple => this.StartPoint.Identifier == this.EndPoint.Identifier;
#endregion
///
/// Determines whether the specified given point contains point.
///
/// The given point.
///
/// true if the specified given point contains point; otherwise, false.
///
public bool ContainsPoint(MusicalPoint givenPoint)
{
bool flagLine = this.StartPoint.LineIndex <= givenPoint.LineIndex
&& givenPoint.LineIndex <= this.EndPoint.LineIndex;
if (!flagLine) {
return false;
}
bool flagBar = this.StartPoint.BarNumber <= givenPoint.BarNumber
&& givenPoint.BarNumber <= this.EndPoint.BarNumber;
return flagBar;
}
#region String representation
/// String representation of the object.
/// Returns value.
public override string ToString() {
var s = new StringBuilder();
s.AppendFormat("Area ({0}-{1})", this.StartPoint, this.EndPoint);
return s.ToString();
}
#endregion
}
}